package de.htw.praxisprojekt.data.draw;

import java.awt.Graphics2D;
import java.awt.Polygon;

import de.htw.praxisprojekt.Vector2D;

public class DrawTriangle extends DrawObject{

	private Vector2D a=new Vector2D();
	private Vector2D b=new Vector2D();
	private Vector2D c=new Vector2D();
	private Polygon polygon;

	public DrawTriangle(Vector2D a,Vector2D b,Vector2D c){
		this.a.set(a);
		this.b.set(b);
		this.c.set(c);
	}

	@Override
	public void draw(Graphics2D g2d){
		g2d.setColor(color);
		int[] x=new int[3];
		x[0]=a.getX();
		x[1]=b.getX();
		x[2]=c.getX();
		int height=g2d.getClipBounds().height;
		int[] y=new int[3];
		y[0]=height-a.getY();
		y[1]=height-b.getY();
		y[2]=height-c.getY();
		polygon=new Polygon(x,y,3);
		g2d.fillPolygon(polygon);
	}
}